package com.wei.czz.framework.common.controller;

import com.wei.czz.common.tool.Result;
import com.wei.czz.framework.common.service.SnowflakeService;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wei
 * date: 2022-09-08 22:08:03
 * className: SnowflakeController 雪花主键获取请求接口类
 * version: 1.0
 * description:
 */
@RestController
@RequestMapping("primary")
@AllArgsConstructor
public class SnowflakeController {

    private static final Logger log = LoggerFactory.getLogger(SnowflakeController.class);

    private final SnowflakeService snowflakeService;

    /**
     * 获取雪花主键接口
     * 单个获取
     * <p>
     * 调用方：
     *  1、浏览器-后台管理页-菜单管理页中调用
     *
     * @return 雪花主键值
     */
    @GetMapping("/get/one")
    public Result<String> getOne() {
        log.info("开始获取雪花主键业务");

        String primaryId = snowflakeService.find();

        log.info("获取雪花主键业务结束");
        return Result.success(primaryId);
    }


}
